package com.sn.campus.config;

import com.sn.campus.dao.TBaseSosDao;
import com.sn.campus.entity.TBaseSos;
import com.sn.campus.utils.SpringUtil;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;


public class SaveData implements Runnable{
//    @Resource
//    private TBaseSosDao tBaseSosDao;

    private Logger log = LogManager.getLogger(getClass());

    private TBaseSos tBaseSos;

    public SaveData(TBaseSos tBaseSos){
        this.tBaseSos = tBaseSos;
    }

    public void getClassRun(){
//        try {
//            Class clazz = Class.forName("com.sn.campus.dao.TBaseSosDao");
////            Class clz = Class.forName("com.sn.campus.entity.TBaseSosServiceImplos");
//            Method insert = clazz.getMethod("insert",TBaseSos.class);
//            insert.invoke(clazz.newInstance(),tBaseSos);
//        } catch (ClassNotFoundException e) {
//            e.printStackTrace();
//        } catch (NoSuchMethodException e) {
//            e.printStackTrace();
//        } catch (IllegalAccessException e) {
//            e.printStackTrace();
//        } catch (InvocationTargetException e) {
//            e.printStackTrace();
//        } catch (InstantiationException e) {
//            e.printStackTrace();
//        }
    }

    @Override
    public void run() {
        log.info("打印参数，保存数据库"+this.tBaseSos.toString());

        TBaseSosDao tBaseSosDao = (TBaseSosDao) SpringUtil.getBean("TBaseSosDao");
        tBaseSosDao.insert(tBaseSos);


    }


}
